const path = require('path')
const webpack = require('webpack')
const htmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
module.exports = {
    entry: {
        path: path.join(__dirname, 'src/index.js')
    },
    output: {
        path: path.join(__dirname, './dist'),
        filename: 'build.js'
    },
    mode: "development",
    devServer: {
        open: true,
        port: 8000,
        contentBase: 'src',
        hot: true
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new htmlWebpackPlugin({
            template: path.join(__dirname, 'src/index.html'),
            filename: "index.html"
        }),
        new VueLoaderPlugin()
    ],
    module: {
        rules: [
            {test: /\.css/, use: ['style-loader', 'css-loader']},
            {test: /\.stylus/, use: ['style-loader', 'css-loader', 'stylus-loader']},
            {test: /\.vue$/, use: ['vue-loader']},
            {test: /\.js$/, use: 'babel-loader', exclude: /node_modules/},
            { test: /\.(ttf|eot|svg|woff|woff2)$/, use: 'url-loader' }, // 处理 字体文件的 loader
            {test: /\.(jpg|jpeg|png|bmp)$/, use: 'url-loader?limit=10000&name=[hash:12][name].[ext]'}
        ]
    }
}